import store from '../stores'
// from_type String	来源1：单品@2：秒杀@3：套餐@4：预售@5：专题|@6：活动||@7：兰密@8：大区@9城市合伙人@10买赠赠品@11箱起@12箱起赠品
export function getOrderState(type) {
  // 订单状态: 1:待付款2:待发货3:待收货4:已收货5:已取消6:付款异常7:超时取消8:已退款
  let state = ''
  switch (type) {
    case 1:
      state = '待付款'
      break
    case 2:
      state = '待发货'
      break
    case 3:
      state = '待收货'
      break
    case 4:
      state = '订单已签收'
      break
    case 5:
      state = '订单已取消'
      break
    case 6:
      state = '付款异常'
      break
    case 7:
      state = '订单超时未付款，已取消'
      break
    case 8:
      state = '退款成功'
      break
    case 9:
      state = '付款中'
      break
    case 10:
      state = '部分发货'
      break
    case 11:
      state = '待分享'
      break
    default:
      break
  }
  return state
}
export function getOrderStateText(type) {
  // 订单状态: 1:待付款2:待发货3:待收货4:已收货5:已取消6:付款异常7:超时取消8:已退款
  let state = ''
  switch (type) {
    case 1:
      state = '待付款'
      break
    case 2:
      state = '待发货'
      break
    case 3:
      state = '待收货'
      break
    case 4:
      state = '订单已签收'
      break
    case 5:
      state = '订单取消'
      break
    case 6:
      state = '付款异常'
      break
    case 7:
      state = '超时取消'
      break
    case 8:
      state = '退款成功'
      break
    case 9:
      state = '付款中'
      break
    case 10:
      state = '部分发货'
      break
    case 11:
      state = '待分享'
      break
    case 12:
      state = '已评价'
      break
    default:
      break
  }
  return state
}

export function getActivityState(type) {
  // 类型，1预售、2促销、3秒杀、4打折、5满减、6满赠
  let state = ''
  switch (type) {
    case 1:
      state = '预售'
      break
    case 2:
      state = '促销'
      break
    case 3:
      state = '秒杀'
      break
    case 4:
      state = '打折'
      break
    case 5:
      state = '满减'
      break
    case 6:
      state = '满赠'
      break
    default:
      break
  }
  return state
}
export function getOrderStateIcon(type) {
  // 1:待付款2:待发货3:待收货4:已收货5:已取消6:付款异常7:超时取消8:已退款10:部分发货11:待分享
  let state = ''
  switch (type) {
    case 1:
      state = 'icon_Waiting'
      break
    case 2:
      state = 'icon_Waiting'
      break
    case 3:
      state = 'icon-complete'
      break
    case 4:
      state = 'icon-complete'
      break
    case 5:
      state = 'icon_delete'
      break
    case 6:
      state = 'icon_cancel'
      break
    case 7:
      state = 'icon_delete'
      break
    case 8:
      state = 'icon-complete'
      break
    case 10:
      state = 'icon_Forthegoods'
      break
    case 11:
      state = 'icon-share'
      break
    default:
      break
  }
  return `/static/images/order/${state}.png`
}
export function getUserLevel(current_member_card_type) {
  if (!store.getters.user) {
    return 'price'
  }
  let state = 'price'
  switch (store.getters.user.current_member_card_type) {
    case 0:
      state = 'price'
      break
    case 1:
      state = 'vip_price'
      break
    case 2:
      state = 'region_price'
      break
    case 3:
      state = 'director_price'
      break
    default:
      break
  }
  return state
}
export function getGreeting() {
  const time = new Date().getHours()
  let greeting = ''
  if (time >= 0 && time < 6) {
    greeting = '凌晨好'
  } else if (time >= 6 && time < 9) {
    greeting = '早上好'
  } else if (time >= 9 && time < 12) {
    greeting = '上午好'
  } else if (time >= 12 && time < 14) {
    greeting = '中午好'
  } else if (time >= 14 && time < 17) {
    greeting = '下午好'
  } else if (time >= 17 && time < 19) {
    greeting = '傍晚好'
  } else if (time >= 19 && time < 22) {
    greeting = '晚上好'
  } else if (time >= 22 && time < 24) {
    greeting = '夜里好'
  }
  return greeting
}
export function getUserLevelName(current_member_card_type) {
  if (!store.getters.user || !store.getters.user.user) {
    return '游客'
  }
  let state = '游客'
  switch (store.getters.user.user.current_member_card_type) {
    case 0:
      state = '普通会员'
      break
    case 1:
      state = 'VIP会员'
      break
    case 2:
      state = '钻石会员'
      break
    case 3:
      state = '董事会员'
      break
    default:
      break
  }
  return state
}

export function getShowPrice(current_member_card_type) {
  if (!store.getters.user || !store.getters.user) {
    return 'vip_price'
  }
  let state = 'vip_price'
  switch (store.getters.user.current_member_card_type) {
    case 0:
      state = 'vip_price'
      break
    case 1:
      state = 'vip_price'
      break
    case 2:
      state = 'region_price'
      break
    case 3:
      state = 'director_price'
      break
    default:
      break
  }
  return state
}

// 根据秒数计算时间
export function secondCountDown(time) {
  let h, m, s
  h = (time / 3600) > 1 ? Math.floor(time / 3600) : 0
  h = parseInt(h) > 9 ? h : '0' + h

  m = (time % 3600) / 60 > 1 ? Math.floor((time % 3600) / 60) : 0
  m = parseInt(m) > 9 ? m : '0' + m

  s = ((time % 3600) % 60) > 0 ? (time % 3600) % 60 : 0
  s = parseInt(s) > 9 ? s : '0' + s

  const result = h + ':' + m + ':' + s
  return result
}